<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>代码生成器配置新 | liran</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="liran note">
    <meta name="keywords" content="我是content">
    <meta name="theme-color" content="#11a8cd">
    <link rel="preload" href="/assets/css/0.styles.0a02024d.css" as="style"><link rel="preload" href="/assets/js/app.3c810432.js" as="script"><link rel="preload" href="/assets/js/2.86379151.js" as="script"><link rel="preload" href="/assets/js/11.ef9c9dd5.js" as="script"><link rel="prefetch" href="/assets/js/10.52a7ec83.js"><link rel="prefetch" href="/assets/js/12.4e438e6d.js"><link rel="prefetch" href="/assets/js/13.962a4298.js"><link rel="prefetch" href="/assets/js/14.cc384da1.js"><link rel="prefetch" href="/assets/js/15.bb801760.js"><link rel="prefetch" href="/assets/js/16.1641b9c9.js"><link rel="prefetch" href="/assets/js/17.0d495285.js"><link rel="prefetch" href="/assets/js/18.8c0ed479.js"><link rel="prefetch" href="/assets/js/19.7294d692.js"><link rel="prefetch" href="/assets/js/20.fd8383bc.js"><link rel="prefetch" href="/assets/js/3.9eb29365.js"><link rel="prefetch" href="/assets/js/4.27f548a3.js"><link rel="prefetch" href="/assets/js/5.735f4bf2.js"><link rel="prefetch" href="/assets/js/6.6918e2a3.js"><link rel="prefetch" href="/assets/js/7.bdd56c44.js"><link rel="prefetch" href="/assets/js/8.a026c9e8.js"><link rel="prefetch" href="/assets/js/9.75871346.js">
    <link rel="stylesheet" href="/assets/css/0.styles.0a02024d.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.svg" alt="liran" class="logo"> <span class="site-name can-hide">liran</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/24112f/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/24112f/" class="nav-link">快速入门</a></li><li class="dropdown-item"><!----> <a href="/pages/779a6e/" class="nav-link">核心功能</a></li><li class="dropdown-item"><!----> <a href="/pages/6b03c5/" class="nav-link">扩展</a></li><li class="dropdown-item"><!----> <a href="/pages/2976a3/" class="nav-link">插件</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="配置" class="dropdown-title"><a href="/pages/56bac0/" class="link-title">配置</a> <span class="title" style="display:none;">配置</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/56bac0/" class="nav-link">使用配置</a></li><li class="dropdown-item"><!----> <a href="/pages/981406/" aria-current="page" class="nav-link router-link-exact-active router-link-active">代码生成器配置新</a></li><li class="dropdown-item"><!----> <a href="/pages/061573/" class="nav-link">代码生成器配置旧</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="liran" class="dropdown-title"><a href="/04.test" class="link-title">liran</a> <span class="title" style="display:none;">liran</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a7b3a6/" class="nav-link">基础</a></li><li class="dropdown-item"><!----> <a href="/pages/4b3960/" class="nav-link">提升</a></li></ul></div></div><div class="nav-item"><a href="/archives/" class="nav-link">归档</a></div> <a href="https://github.com/baomidou/mybatis-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/24112f/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/24112f/" class="nav-link">快速入门</a></li><li class="dropdown-item"><!----> <a href="/pages/779a6e/" class="nav-link">核心功能</a></li><li class="dropdown-item"><!----> <a href="/pages/6b03c5/" class="nav-link">扩展</a></li><li class="dropdown-item"><!----> <a href="/pages/2976a3/" class="nav-link">插件</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="配置" class="dropdown-title"><a href="/pages/56bac0/" class="link-title">配置</a> <span class="title" style="display:none;">配置</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/56bac0/" class="nav-link">使用配置</a></li><li class="dropdown-item"><!----> <a href="/pages/981406/" aria-current="page" class="nav-link router-link-exact-active router-link-active">代码生成器配置新</a></li><li class="dropdown-item"><!----> <a href="/pages/061573/" class="nav-link">代码生成器配置旧</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="liran" class="dropdown-title"><a href="/04.test" class="link-title">liran</a> <span class="title" style="display:none;">liran</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a7b3a6/" class="nav-link">基础</a></li><li class="dropdown-item"><!----> <a href="/pages/4b3960/" class="nav-link">提升</a></li></ul></div></div><div class="nav-item"><a href="/archives/" class="nav-link">归档</a></div> <a href="https://github.com/baomidou/mybatis-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>使用配置</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/56bac0/" class="sidebar-link">使用配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>代码生成器配置</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/981406/" aria-current="page" class="active sidebar-link">代码生成器配置新</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/981406/#数据库配置-datasourceconfig" class="sidebar-link">数据库配置(DataSourceConfig)</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/981406/#基础配置" class="sidebar-link">基础配置</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#可选配置" class="sidebar-link">可选配置</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/981406/#全局配置-globalconfig" class="sidebar-link">全局配置(GlobalConfig)</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#包配置-packageconfig" class="sidebar-link">包配置(PackageConfig)</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#模板配置-templateconfig" class="sidebar-link">模板配置(TemplateConfig)</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#注入配置-injectionconfig" class="sidebar-link">注入配置(InjectionConfig)</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#策略配置-strategyconfig" class="sidebar-link">策略配置(StrategyConfig)</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/981406/#entity-策略配置" class="sidebar-link">Entity 策略配置</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#controller-策略配置" class="sidebar-link">Controller 策略配置</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#service-策略配置" class="sidebar-link">Service 策略配置</a></li><li class="sidebar-sub-header"><a href="/pages/981406/#mapper-策略配置" class="sidebar-link">Mapper 策略配置</a></li></ul></li></ul></li><li><a href="/pages/061573/" class="sidebar-link">代码生成器配置旧</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><!----> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><img src="">
          代码生成器配置新
        </h1>  <div class="theme-vdoing-content content__default"><h2 id="数据库配置-datasourceconfig"><a href="#数据库配置-datasourceconfig" class="header-anchor">#</a> 数据库配置(DataSourceConfig)</h2> <h3 id="基础配置"><a href="#基础配置" class="header-anchor">#</a> 基础配置</h3> <table><thead><tr><th>属性</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>url</td> <td>jdbc 路径</td> <td>jdbc:mysql://127.0.0.1:3306/mybatis-plus</td></tr> <tr><td>username</td> <td>数据库账号</td> <td>root</td></tr> <tr><td>password</td> <td>数据库密码</td> <td>123456</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">DataSourceConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token string">&quot;jdbc:mysql://127.0.0.1:3306/mybatis-plus&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;root&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;123456&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="可选配置"><a href="#可选配置" class="header-anchor">#</a> 可选配置</h3> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>dbQuery(IDbQuery)</td> <td>数据库查询</td> <td>new MySqlQuery()</td></tr> <tr><td>schema(String)</td> <td>数据库 schema(部分数据库适用)</td> <td>mybatis-plus</td></tr> <tr><td>typeConvert(ITypeConvert)</td> <td>数据库类型转换器</td> <td>new MySqlTypeConvert()</td></tr> <tr><td>keyWordsHandler(IKeyWordsHandler)</td> <td>数据库关键字处理器</td> <td>new MySqlKeyWordsHandler()</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">DataSourceConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token string">&quot;jdbc:mysql://127.0.0.1:3306/mybatis-plus&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;root&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;123456&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">dbQuery</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">MySqlQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">schema</span><span class="token punctuation">(</span><span class="token string">&quot;mybatis-plus&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">typeConvert</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">MySqlTypeConvert</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">keyWordsHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">MySqlKeyWordsHandler</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="全局配置-globalconfig"><a href="#全局配置-globalconfig" class="header-anchor">#</a> 全局配置(GlobalConfig)</h2> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>fileOverride</td> <td>覆盖已生成文件</td> <td>默认值:false</td></tr> <tr><td>disableOpenDir</td> <td>禁止打开输出目录</td> <td>默认值:true</td></tr> <tr><td>outputDir(String)</td> <td>指定输出目录</td> <td>/opt/baomidou/ 默认值: windows:D:// linux or mac : /tmp</td></tr> <tr><td>author(String)</td> <td>作者名</td> <td>baomidou 默认值:作者</td></tr> <tr><td>enableKotlin</td> <td>开启 kotlin 模式</td> <td>默认值:false</td></tr> <tr><td>enableSwagger</td> <td>开启 swagger 模式</td> <td>默认值:false</td></tr> <tr><td>dateType(DateType)</td> <td>时间策略</td> <td>DateType.ONLY_DATE 默认值: DateType.TIME_PACK</td></tr> <tr><td>commentDate(String)</td> <td>注释日期</td> <td>默认值: yyyy-MM-dd</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">GlobalConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">fileOverride</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">outputDir</span><span class="token punctuation">(</span><span class="token string">&quot;/opt/baomidou&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">author</span><span class="token punctuation">(</span><span class="token string">&quot;baomidou&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableKotlin</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableSwagger</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">dateType</span><span class="token punctuation">(</span><span class="token class-name">DateType</span><span class="token punctuation">.</span>TIME_PACK<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">commentDate</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy-MM-dd&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="包配置-packageconfig"><a href="#包配置-packageconfig" class="header-anchor">#</a> 包配置(PackageConfig)</h2> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>parent(String)</td> <td>父包名</td> <td>默认值:com.baomidou</td></tr> <tr><td>moduleName(String)</td> <td>父包模块名</td> <td>默认值:无</td></tr> <tr><td>entity(String)</td> <td>Entity 包名</td> <td>默认值:entity</td></tr> <tr><td>service(String)</td> <td>Service 包名</td> <td>默认值:service</td></tr> <tr><td>serviceImpl(String)</td> <td>Service Impl 包名</td> <td>默认值:service.impl</td></tr> <tr><td>mapper(String)</td> <td>Mapper 包名</td> <td>默认值:mapper</td></tr> <tr><td>mapperXml(String)</td> <td>Mapper XML 包名</td> <td>默认值:mapper.xml</td></tr> <tr><td>controller(String)</td> <td>Controller 包名</td> <td>默认值:controller</td></tr> <tr><td>other(String)</td> <td>自定义文件包名</td> <td>输出自定义文件时所用到的包名</td></tr> <tr><td>pathInfo(Map&lt;OutputFile, String&gt;)</td> <td>路径配置信息</td> <td>Collections.singletonMap(OutputFile.mapperXml, &quot;D://&quot;)</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">PackageConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">parent</span><span class="token punctuation">(</span><span class="token string">&quot;com.baomidou.mybatisplus.samples.generator&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">moduleName</span><span class="token punctuation">(</span><span class="token string">&quot;sys&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">entity</span><span class="token punctuation">(</span><span class="token string">&quot;po&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">service</span><span class="token punctuation">(</span><span class="token string">&quot;service&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">serviceImpl</span><span class="token punctuation">(</span><span class="token string">&quot;service.impl&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">mapper</span><span class="token punctuation">(</span><span class="token string">&quot;mapper&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">mapperXml</span><span class="token punctuation">(</span><span class="token string">&quot;mapper.xml&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">controller</span><span class="token punctuation">(</span><span class="token string">&quot;controller&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">other</span><span class="token punctuation">(</span><span class="token string">&quot;other&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">pathInfo</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token class-name">OutputFile</span><span class="token punctuation">.</span>mapperXml<span class="token punctuation">,</span> <span class="token string">&quot;D://&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><h2 id="模板配置-templateconfig"><a href="#模板配置-templateconfig" class="header-anchor">#</a> 模板配置(TemplateConfig)</h2> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>disable</td> <td>禁用所有模板</td> <td></td></tr> <tr><td>disable(TemplateType...)</td> <td>禁用模板</td> <td>TemplateType.ENTITY</td></tr> <tr><td>entity(String)</td> <td>设置实体模板路径(JAVA)</td> <td>/templates/entity.java</td></tr> <tr><td>entityKt(String)</td> <td>设置实体模板路径(kotlin)</td> <td>/templates/entity.java</td></tr> <tr><td>service(String)</td> <td>设置 service 模板路径</td> <td>/templates/service.java</td></tr> <tr><td>serviceImpl(String)</td> <td>设置 serviceImpl 模板路径</td> <td>/templates/serviceImpl.java</td></tr> <tr><td>mapper(String)</td> <td>设置 mapper 模板路径</td> <td>/templates/mapper.java</td></tr> <tr><td>mapperXml(String)</td> <td>设置 mapperXml 模板路径</td> <td>/templates/mapper.xml</td></tr> <tr><td>controller(String)</td> <td>设置 controller 模板路径</td> <td>/templates/controller.java</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">TemplateConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">disable</span><span class="token punctuation">(</span><span class="token class-name">TemplateType</span><span class="token punctuation">.</span>ENTITY<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">entity</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/entity.java&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">service</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/service.java&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">serviceImpl</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/serviceImpl.java&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">mapper</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/mapper.java&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">mapperXml</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/mapper.xml&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">controller</span><span class="token punctuation">(</span><span class="token string">&quot;/templates/controller.java&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="注入配置-injectionconfig"><a href="#注入配置-injectionconfig" class="header-anchor">#</a> 注入配置(InjectionConfig)</h2> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>beforeOutputFile(BiConsumer&lt;TableInfo, Map&lt;String, Object&gt;&gt;)</td> <td>输出文件之前消费者</td> <td></td></tr> <tr><td>customMap(Map&lt;String, Object&gt;)</td> <td>自定义配置 Map 对象</td> <td>Collections.singletonMap(&quot;test&quot;, &quot;baomidou&quot;)</td></tr> <tr><td>customFile(Map&lt;String, String&gt;)</td> <td>自定义配置模板文件</td> <td>Collections.singletonMap(&quot;test.txt&quot;, &quot;/templates/test.vm&quot;)</td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">InjectionConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">beforeOutputFile</span><span class="token punctuation">(</span><span class="token punctuation">(</span>tableInfo<span class="token punctuation">,</span> objectMap<span class="token punctuation">)</span> <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;tableInfo: &quot;</span> <span class="token operator">+</span> tableInfo<span class="token punctuation">.</span><span class="token function">getEntityName</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot; objectMap: &quot;</span> <span class="token operator">+</span> objectMap<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">customMap</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token string">&quot;test&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;baomidou&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">customFile</span><span class="token punctuation">(</span><span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">singletonMap</span><span class="token punctuation">(</span><span class="token string">&quot;test.txt&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;/templates/test.vm&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h2 id="策略配置-strategyconfig"><a href="#策略配置-strategyconfig" class="header-anchor">#</a> 策略配置(StrategyConfig)</h2> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>enableCapitalMode</td> <td>开启大写命名</td> <td>默认值:false</td></tr> <tr><td>enableSkipView</td> <td>开启跳过视图</td> <td>默认值:false</td></tr> <tr><td>disableSqlFilter</td> <td>禁用 sql 过滤</td> <td>默认值:true，语法不能支持使用 sql 过滤表的话，可以考虑关闭此开关</td></tr> <tr><td>enableSchema</td> <td>启用 schema</td> <td>默认值:false，多 schema 场景的时候打开</td></tr> <tr><td>likeTable(LikeTable)</td> <td>模糊表匹配(sql 过滤)</td> <td>likeTable 与 notLikeTable 只能配置一项</td></tr> <tr><td>notLikeTable(LikeTable)</td> <td>模糊表排除(sql 过滤)</td> <td>likeTable 与 notLikeTable 只能配置一项</td></tr> <tr><td>addInclude(String...)</td> <td>增加表匹配(内存过滤)</td> <td>include 与 exclude 只能配置一项</td></tr> <tr><td>addExclude(String...)</td> <td>增加表排除匹配(内存过滤)</td> <td>include 与 exclude 只能配置一项</td></tr> <tr><td>addTablePrefix(String...)</td> <td>增加过滤表前缀</td> <td></td></tr> <tr><td>addTableSuffix(String...)</td> <td>增加过滤表后缀</td> <td></td></tr> <tr><td>addFieldPrefix(String...)</td> <td>增加过滤字段前缀</td> <td></td></tr> <tr><td>addFieldSuffix(String...)</td> <td>增加过滤字段后缀</td> <td></td></tr> <tr><td>entityBuilder</td> <td>实体策略配置</td> <td></td></tr> <tr><td>controllerBuilder</td> <td>controller 策略配置</td> <td></td></tr> <tr><td>mapperBuilder</td> <td>mapper 策略配置</td> <td></td></tr> <tr><td>serviceBuilder</td> <td>service 策略配置</td> <td></td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">StrategyConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableCapitalMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableSkipView</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">disableSqlFilter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">likeTable</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">LikeTable</span><span class="token punctuation">(</span><span class="token string">&quot;USER&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addInclude</span><span class="token punctuation">(</span><span class="token string">&quot;t_simple&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addTablePrefix</span><span class="token punctuation">(</span><span class="token string">&quot;t_&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;c_&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addFieldSuffix</span><span class="token punctuation">(</span><span class="token string">&quot;_flag&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="entity-策略配置"><a href="#entity-策略配置" class="header-anchor">#</a> Entity 策略配置</h3> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>nameConvert(INameConvert)</td> <td>名称转换实现</td> <td></td></tr> <tr><td>superClass(Class&lt;?&gt;)</td> <td>设置父类</td> <td>BaseEntity.class</td></tr> <tr><td>superClass(String)</td> <td>设置父类</td> <td>com.baomidou.global.BaseEntity</td></tr> <tr><td>disableSerialVersionUID</td> <td>禁用生成 serialVersionUID</td> <td>默认值:true</td></tr> <tr><td>enableColumnConstant</td> <td>开启生成字段常量</td> <td>默认值:false</td></tr> <tr><td>enableChainModel</td> <td>开启链式模型</td> <td>默认值:false</td></tr> <tr><td>enableLombok</td> <td>开启 lombok 模型</td> <td>默认值:false</td></tr> <tr><td>enableRemoveIsPrefix</td> <td>开启 Boolean 类型字段移除 is 前缀</td> <td>默认值:false</td></tr> <tr><td>enableTableFieldAnnotation</td> <td>开启生成实体时生成字段注解</td> <td>默认值:false</td></tr> <tr><td>enableActiveRecord</td> <td>开启 ActiveRecord 模型</td> <td>默认值:false</td></tr> <tr><td>versionColumnName(String)</td> <td>乐观锁字段名(数据库)</td> <td></td></tr> <tr><td>versionPropertyName(String)</td> <td>乐观锁属性名(实体)</td> <td></td></tr> <tr><td>logicDeleteColumnName(String)</td> <td>逻辑删除字段名(数据库)</td> <td></td></tr> <tr><td>logicDeletePropertyName(String)</td> <td>逻辑删除属性名(实体)</td> <td></td></tr> <tr><td>naming</td> <td>数据库表映射到实体的命名策略</td> <td>默认下划线转驼峰命名:NamingStrategy.underline_to_camel</td></tr> <tr><td>columnNaming</td> <td>数据库表字段映射到实体的命名策略</td> <td>默认为 null，未指定按照 naming 执行</td></tr> <tr><td>addSuperEntityColumns(String...)</td> <td>添加父类公共字段</td> <td></td></tr> <tr><td>addIgnoreColumns(String...)</td> <td>添加忽略字段</td> <td></td></tr> <tr><td>addTableFills(IFill...)</td> <td>添加表字段填充</td> <td></td></tr> <tr><td>addTableFills(List&lt;IFill&gt;)</td> <td>添加表字段填充</td> <td></td></tr> <tr><td>idType(IdType)</td> <td>全局主键类型</td> <td></td></tr> <tr><td>convertFileName(ConverterFileName)</td> <td>转换文件名称</td> <td></td></tr> <tr><td>formatFileName(String)</td> <td>格式化文件名称</td> <td></td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">StrategyConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">entityBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">superClass</span><span class="token punctuation">(</span><span class="token class-name">BaseEntity</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">disableSerialVersionUID</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableChainModel</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableLombok</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableRemoveIsPrefix</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableTableFieldAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableActiveRecord</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">versionColumnName</span><span class="token punctuation">(</span><span class="token string">&quot;version&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">versionPropertyName</span><span class="token punctuation">(</span><span class="token string">&quot;version&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">logicDeleteColumnName</span><span class="token punctuation">(</span><span class="token string">&quot;deleted&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">logicDeletePropertyName</span><span class="token punctuation">(</span><span class="token string">&quot;deleteFlag&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">naming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>no_change<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">columnNaming</span><span class="token punctuation">(</span><span class="token class-name">NamingStrategy</span><span class="token punctuation">.</span>underline_to_camel<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addSuperEntityColumns</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;created_by&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;created_time&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;updated_by&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;updated_time&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addIgnoreColumns</span><span class="token punctuation">(</span><span class="token string">&quot;age&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addTableFills</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Column</span><span class="token punctuation">(</span><span class="token string">&quot;create_time&quot;</span><span class="token punctuation">,</span> <span class="token class-name">FieldFill</span><span class="token punctuation">.</span>INSERT<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">addTableFills</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Property</span><span class="token punctuation">(</span><span class="token string">&quot;updateTime&quot;</span><span class="token punctuation">,</span> <span class="token class-name">FieldFill</span><span class="token punctuation">.</span>INSERT_UPDATE<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">idType</span><span class="token punctuation">(</span><span class="token class-name">IdType</span><span class="token punctuation">.</span>AUTO<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sEntity&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h3 id="controller-策略配置"><a href="#controller-策略配置" class="header-anchor">#</a> Controller 策略配置</h3> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>superClass(Class&lt;?&gt;)</td> <td>设置父类</td> <td>BaseController.class</td></tr> <tr><td>superClass(String)</td> <td>设置父类</td> <td>com.baomidou.global.BaseController</td></tr> <tr><td>enableHyphenStyle</td> <td>开启驼峰转连字符</td> <td>默认值:false</td></tr> <tr><td>enableRestStyle</td> <td>开启生成@RestController 控制器</td> <td>默认值:false</td></tr> <tr><td>convertFileName(ConverterFileName)</td> <td>转换文件名称</td> <td></td></tr> <tr><td>formatFileName(String)</td> <td>格式化文件名称</td> <td></td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">StrategyConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">controllerBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">superClass</span><span class="token punctuation">(</span><span class="token class-name">BaseController</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableHyphenStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableRestStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sAction&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="service-策略配置"><a href="#service-策略配置" class="header-anchor">#</a> Service 策略配置</h3> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>superServiceClass(Class&lt;?&gt;)</td> <td>设置 service 接口父类</td> <td>BaseService.class</td></tr> <tr><td>superServiceClass(String)</td> <td>设置 service 接口父类</td> <td>com.baomidou.global.BaseService</td></tr> <tr><td>superServiceImplClass(Class&lt;?&gt;)</td> <td>设置 service 实现类父类</td> <td>BaseServiceImpl.class</td></tr> <tr><td>superServiceImplClass(String)</td> <td>设置 service 实现类父类</td> <td>com.baomidou.global.BaseServiceImpl</td></tr> <tr><td>convertServiceFileName(ConverterFileName)</td> <td>转换 service 接口文件名称</td> <td></td></tr> <tr><td>convertServiceImplFileName(ConverterFileName)</td> <td>转换 service 实现类文件名称</td> <td></td></tr> <tr><td>formatServiceFileName(String)</td> <td>格式化 service 接口文件名称</td> <td></td></tr> <tr><td>formatServiceImplFileName(String)</td> <td>格式化 service 实现类文件名称</td> <td></td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">StrategyConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">serviceBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">superServiceClass</span><span class="token punctuation">(</span><span class="token class-name">BaseService</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">superServiceImplClass</span><span class="token punctuation">(</span><span class="token class-name">BaseServiceImpl</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatServiceFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sService&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatServiceImplFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sServiceImp&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="mapper-策略配置"><a href="#mapper-策略配置" class="header-anchor">#</a> Mapper 策略配置</h3> <table><thead><tr><th>方法</th> <th>说明</th> <th>示例</th></tr></thead> <tbody><tr><td>superClass(Class&lt;?&gt;)</td> <td>设置父类</td> <td>BaseMapper.class</td></tr> <tr><td>superClass(String)</td> <td>设置父类</td> <td>com.baomidou.global.BaseMapper</td></tr> <tr><td>enableMapperAnnotation</td> <td>开启 @Mapper 注解</td> <td>默认值:false</td></tr> <tr><td>enableBaseResultMap</td> <td>启用 BaseResultMap 生成</td> <td>默认值:false</td></tr> <tr><td>enableBaseColumnList</td> <td>启用 BaseColumnList</td> <td>默认值:false</td></tr> <tr><td>cache(Class&lt;? extends Cache&gt;)</td> <td>设置缓存实现类</td> <td>MyMapperCache.class</td></tr> <tr><td>convertMapperFileName(ConverterFileName)</td> <td>转换 mapper 类文件名称</td> <td></td></tr> <tr><td>convertXmlFileName(ConverterFileName)</td> <td>转换 xml 文件名称</td> <td></td></tr> <tr><td>formatMapperFileName(String)</td> <td>格式化 mapper 文件名称</td> <td></td></tr> <tr><td>formatXmlFileName(String)</td> <td>格式化 xml 实现类文件名称</td> <td></td></tr></tbody></table> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">new</span> <span class="token class-name">StrategyConfig<span class="token punctuation">.</span>Builder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">mapperBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">superClass</span><span class="token punctuation">(</span><span class="token class-name">BaseMapper</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableMapperAnnotation</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableBaseResultMap</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">enableBaseColumnList</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">cache</span><span class="token punctuation">(</span><span class="token class-name">MyMapperCache</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatMapperFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sDao&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">formatXmlFileName</span><span class="token punctuation">(</span><span class="token string">&quot;%sXml&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>  <div class="page-edit"><div class="edit-link"><a href="https://github.com/baomidou/mybatis-plus/edit/master/docs/02.配置/02.代码生成器配置/01.代码生成器配置新.md" target="_blank" rel="noopener noreferrer">编辑</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/56bac0/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">使用配置</div></a> <a href="/pages/061573/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">代码生成器配置旧</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/56bac0/" class="prev">使用配置</a></span> <span class="next"><a href="/pages/061573/">代码生成器配置旧</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="https://github.com/baomidou" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://gitee.com/baomidou" title="Gitee" target="_blank" class="iconfont icon-gitee"></a><a href="mailto:koyangslash@gmail.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2016-2021
    <span><a href="http://baomidou.com" target="_blank" style="font-weight:bold">Team Baomidou</a> | Sponsored by <a href="https://www.jetbrains.com" target="_blank" style="font-weight:bold">JetBrains</a> | <a href="http://beian.miit.gov.cn/" target=_blank>渝ICP备2021000141号</a><p>友情链接：<a href="http://aizuda.com" target="_blank" style="font-weight:bold">AiZuDa</a> | <a href="https://dyang.top/" target="_blank" style="font-weight:bold">D.Yang</a> | <a href="https://blog.nancheung.com/" target="_blank" style="font-weight:bold">NanCheung</a></p></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.3c810432.js" defer></script><script src="/assets/js/2.86379151.js" defer></script><script src="/assets/js/11.ef9c9dd5.js" defer></script>
  </body>
</html>